<!DOCTYPE html>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
    
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html>
	<head>
		<meta charset="utf-8">
		<title>Welcome</title>
	</head>
	 
	<body>
		
		<div>
			<input type="text" id="gege" />
			<input type="text" id="miao" />
			<input type="button" id="geButton" value="gege" />
			<span id="returnV" style="display:none"></span>
		</div>
		
		<form method="POST" enctype="multipart/form-data" action="up">
  				File to upload: <input type="file" name="upfile"><br/>
  				Notes about the file: <input type="text" name="note"><br/>
  			<br/>
  			<input type="submit" value="Press"> to upload the file!
		</form>
		
		<div id="gelist">
			<c:forEach items="${list}" var="s">
     			<span><c:out value="${s.id}"></c:out></span>
     			<span><c:out value="${s.content}"></c:out></span>
     			<span><c:out value="${s.dtime}"></c:out></span>
     			<br />
     		</c:forEach>
		</div>
		
		<div>
			<input type="text" id="sayGe" />
			<input type="button" id="sayButton" value="say" />
		</div>		
	</body>
	
	<script type="text/javascript" src="js/jquery.js"> </script>
	
	<script type="text/javascript">
		window.onload = function () {
			$("#geButton").on("click", function() {
				var gege = $("#gege").val();
				var miao = $("#miao").val();
				
				$.post("gege2", {'ge' : gege, 'miao' : miao}, function(result){
					$("#returnV").html(result.ge+"!!!"+result.miao);
					$("#returnV").show();
				});
				
				
			});
			
			$("#sayButton").on("click", function() {
				$.post("sayGe", {'ge1' : $("#sayGe").val()}, function(result) {
					$("#gelist").html("");
					var h = "";
					for (var i=0;i<result.length;i++) {
						h += '<span>' + result[i].id + '</span>';
						h += '<span>' + result[i].content + '</span>';
						h += '<span>' + result[i].dtime + '</span>';
						h += '<br />';
					}
					$("#gelist").html(h);
					
				});
			});
		};
	</script>
	
</html>
